static-delta: limit the number of writes in process to 1
authorGiuseppe Scrivano <gscrivan@redhat.com>
Fri, 16 Jan 2015 18:21:27 +0000 (19:21 +0100)
committerColin Walters <walters@verbum.org>
Tue, 20 Jan 2015 14:51:02 +0000 (09:51 -0500)
This will avoid too many open files at the same time that could cause
an EMFILE error.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit bc092b06f0e34e93f7d6102957bf55fd7ffd1b9e)

src/libostree/ostree-repo-static-delta-processing.c

index 13abc6c0c613b4429f78a4cb9db010cdbd8ccbd1..a663b84c6759c24033b465c8264c57c12793a77c 100644 (file)
@@ -265,6 +265,11 @@ _ostree_static_delta_part_execute_raw (OstreeRepo      *repo,
       guint8 opcode;
       OstreeStaticDeltaOperation *op;
 
+      /* Limit the number of outstanding writes to 1 to prevent too many open files
+         at the same time.  */
+      while (state->outstanding_content_writes > 1)
+        g_main_context_iteration (state->content_writing_context, TRUE);
+
       if (state->object_start)
         {
           if (!open_output_target (state, cancellable, error))